#!/usr/bin/python
# -*- coding: utf-8 -*-

from main.views import render_response

from diveintopython.models import Document, Translation
from diveintopython.forms import DocumentForm, TranslationForm

def home(request):
    documents = Document.all().order("order")
    return render_response(request, "diveintopython/home.html", locals())

def translation_create(request, id):
    document = Document.get_by_id(int(id))
    form = TranslationForm()
    return render_response(request, "diveintopython/translation_form.html", locals())

def document_detail(request, id):
    document = Document.get_by_id(int(id))
    translations = Translation.all().filter("document =", document)
    return render_response(request, "diveintopython/document_detail.html", locals())

def document_create(request):
    form = DocumentForm()
    return render_response(request, "diveintopython/document_form.html", locals())

def translation_detail(request, id):
    translation = Translation.get_by_id(int(id))
    return render_response(request, "diveintopython/translation_detail.html", locals())
